package org.langqiao.experiment.experiment2;
public class NumTower{
	
	public static void getTower_for(int n){
		for(int i=1;i<n+1;i++){
			printSpace(n-i);
			for(int j=1;j<=i;j++){
				System.out.print(j+"\t");
			}
			for(int k=i-1;k>0;k--){
				System.out.print(k+"\t");
			}
			System.out.println();
		}
    }

	public static void getTower_digui(int n){
		printSpace(n-1);
		if(n==1){
			System.out.print(1+"\t");
		}else {
			for(int i=n;i>0;i--){
				System.out.print(i+"\t");
				getTower_digui(n-1);
			}
		}
		System.out.println();
	}

	public static void printSpace(int n){
		for(int i=0;i<n;i++)
			System.out.print(" \t");
	}
	public static void main(String []args){
		System.out.println("循环的方法获得数字塔：");
		getTower_for(5);
		System.out.println("递归的方法获得数字塔：");
		getTower_digui(5);
	}
}